package net.anzhuo.service.impl;

import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.dao.GsGudongMapper;
import net.anzhuo.entity.GsGudong;
import net.anzhuo.service.GsGudongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GsGudongServiceImpl implements GsGudongService {

	@Autowired
	private GsGudongMapper gsGudongMapper;

	@Override
	public PaginationVO<GsGudong> getListWithPage(GsGudong gsGudong) {
		PaginationVO<GsGudong> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsGudongMapper.getListWithPage(gsGudong));
		paginationVO.setTotalCount(gsGudongMapper.getCount(gsGudong));
		paginationVO.setTotalPage((gsGudongMapper.getCount(gsGudong) + gsGudong.getPageSize() -1)  / gsGudong.getPageSize());
		paginationVO.setPageNo(gsGudong.getPageNo());
		return paginationVO;
	}

	@Override
	public GsGudong getById(Long id) {
		return gsGudongMapper.getById(id);
	}

	@Override
	public List<GsGudong> getList() {
		return gsGudongMapper.getList();
	}

	@Override
	public List<GsGudong> getList(GsGudong gsGudong) {
		return gsGudongMapper.getListByQuery(gsGudong);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsGudong gsGudong) {
		gsGudongMapper.update(gsGudong);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsGudong gsGudong) {
		gsGudongMapper.save(gsGudong);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsGudong gsGudong) {
		 gsGudongMapper.delete(gsGudong);
		
	}

	@Override
	public List<GsGudong> getByMd5(String md5) {
		return gsGudongMapper.getByMd5(md5);
	}
	@Override
	public List<GsGudong> getByName(GsGudong gsGudong) {
		return gsGudongMapper.getByName(gsGudong);
	}

	@Override
	public void deleteByID(GsGudong gsGudong) {
		// TODO Auto-generated method stub
		gsGudongMapper.deleteByID(gsGudong);
	}
}
